#ifndef __NETAUDIO_H__
#define __NETAUDIO_H__

#include <pthread.h>
#include <stdbool.h>
#include "Sqlist_List.h"
#include "IBT_List.h"
#include "NetCore.h" 



typedef struct CAudioPlayPacket//接收上位机的消息
{
	unsigned char*	m_buffer;
	int 			m_length;
	IBTList 		queue;
}CAudioPlayPacket;


typedef struct CAudioSendPakcet
{
	unsigned char* 		m_buffer;
	int 				m_length;
	int 				m_count;		//
	pthread_mutex_t 	m_hmutex;
	IBTList 			queue;
}CAudioSendPakcet;		//发送数据包链表


typedef struct CAudioSendList
{	
	struct conn*		m_conn;				//表中每个人绑定的conn
	List_Head 			Head;
}CAudioSendList;

typedef struct CAudioOutList
{
	unsigned char *	m_buffer;
	unsigned int Length;
	IBTList		 queue;
}CAudioOutList;


typedef struct CNetAudioList   //总的结构体
{
	bool 		 		m_Play_Switch;			//播放线程控制开关
	unsigned char		m_Play_Number;
	pthread_t			m_Play_ThreadID;		//播放音频线程ID
	pthread_mutex_t*    m_Packet_hmutex;		//发送数据包添加和删除锁
	IBTListQueue		m_Play_Queue;			//播放队列
	bool 				m_Send_Swicht;			//发送线程控制开关
	pthread_t			m_Send_ThreadID;		//发送数据包上传线程ID
	pthread_mutex_t*	m_Send_hmutex;			//发送人员添加和删除锁
	unsigned char 		m_Send_Number;			//需要发送的上位机人数
	CAudioSendList		m_Send_List;			//发送人员表
	IBTListQueue		m_SendPakcet_Queue;		//发送数据包队列
}CNetAudioList;




void Net_AudioPlayStart();
void Net_AudioList_init();
int Audio_FilterCallback(struct conn *c, DVRIP *pHead);
//void Net_AudioSend_AddNumber(struct conn *m_conn);
void Net_AudioSend_DeleteNumber(struct conn* m_conn);

void Net_AudioPlayStop();
void Net_AudioSendStop(struct conn *m_conn);











#endif

